﻿<!DOCTYPE HTML>
<html>
{include file="public:header_css"}
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页
	<span class="c-gray en">&gt;</span>
	学生管理
	<span class="c-gray en">&gt;</span>
	添加课程
	<a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a>
</nav>
<div class="page-container">
	<form class="form form-horizontal" id="form-article-add">
		<input type="hidden" value="{$stu_id}" id="stu_id">
		<div id="tab-system" class="HuiTab">

			<div class="tabBar cl">
				<span>集体班</span>
				<span>一对多</span>
				<span>一对一</span>
			</div>
			<!--集体班-->
			<div class="tabCon" id="tabCont">
				<div class="mt-20">
					<table class="table table-border table-bordered table-hover table-bg table-sort">
						<thead>
						<tr class="text-c">
							<th width="3"><input type="checkbox" name="" value=""></th>
							<th width="300">课程名称</th>
						</tr>
						</thead>
						<tbody>
						{foreach name="course_list" item="val" key="key"}
							<tr class="text-c">
								<td><input type="checkbox" value="jt-{$val.course_id}" name=""></td>
								<td>{$val.course_name}</td>
							</tr>
						{/foreach}
						</tbody>
					</table>
				</div>
			</div>
			<!--对多-->
			<div class="tabCon">
				<div class="mt-20">
					<table class="table table-border table-bordered table-hover table-bg table-sort">
						<thead>
						<tr class="text-c">
							<th width="3"></th>
							<th width="300">课程名称</th>
						</tr>
						</thead>
						<tbody>
						{foreach name="course_list1" item="val" key="key"}
						<tr class="text-c">
							<td><input type="checkbox" value="ydd-{$val.course_id}" name=""
									   onclick="add1('添加课程','{:url(\'add_one\',[\'course_id\' => $val.course_id , \'store_id\' => $val.store_id, \'stu_id\'=>$stu_id])}')"></td>
							<td>{$val.course_name}</td>
						</tr>
						{/foreach}
						</tbody>
					</table>
				</div>
			</div>

			<!--一对一-->
			<div class="tabCon">
				<div class="mt-20">
					<table class="table table-border table-bordered table-hover table-bg table-sort">
						<thead>
						<tr class="text-c">
							<th width="3"></th>
							<th width="300">课程名称</th>
						</tr>
						</thead>
						<tbody>
						{foreach name="course_list2" item="val" key="key"}
						<tr class="text-c">
							<td><input type="checkbox" value="ydy-{$val.course_id}" name=""
									   onclick="add1('添加课程','{:url(\'add_one\',[\'course_id\' => $val.course_id , \'store_id\' => $val.store_id, \'stu_id\'=>$stu_id])}')"></td>
							<td>{$val.course_name}</td>
						</tr>
						{/foreach}
						</tbody>
					</table>
				</div>
			</div>

		</div>

		<div class="row cl">
			<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
				<button class="btn btn-primary radius" type="submit" id="submit">&nbsp;&nbsp;提交&nbsp;&nbsp;</button>
				<a class="btn btn-warning radius" href="{:url('student/index')}">&nbsp;&nbsp;返回&nbsp;&nbsp;</a>
			</div>
		</div>

	</form>
</div>

{include file="public:footer_js"}

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="__STATIC__/admin/lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="__STATIC__/admin/lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="__STATIC__/admin/lib/laypage/1.2/laypage.js"></script>
<script type="text/javascript" src="__STATIC__/admin/lib/laypage/1.2/laypage.js"></script>

<script type="text/javascript">

    $(function(){
        $('.skin-minimal input').iCheck({
            checkboxClass: 'icheckbox-blue',
            radioClass: 'iradio-blue',
            increaseArea: '20%'
        });
        $("#tab-system").Huitab({
            index:0
        });

    });


    //一对多或一对一
    function add1(title,url,id,w,h){
        layer_show(title,url,900,700);
    }

    //异步提交
    $("#submit").click(function(){

        var stu_id = $('#stu_id').val();
        //选中课程
        var arr=[];
        //监听选中按钮
        $.each($('#tabCont input:checkbox'),function(){
            if(this.checked){
                arr.push($(this).val());
            }
        });

        //异步提交
		$.post(
		    "{:url('add')}",
			{
			    stu_id     : stu_id,
                course_arr : JSON.stringify(arr)
			},
            function (res) {

                if(res.code === 1){
                    layer.msg(res.msg,{icon:6,time:1000});
					location.href = "{:url('student_arrange/index')}"+"?stu_id="+res.data;
                }else{
                    layer.msg(res.msg,{icon:6,time:1000});
                }
            }
        );
    });



</script>
</body>

</html>